/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uk.ac.staffs.student.autopilot;

/**
 *
 * @author Peter
 */
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

import org.apache.log4j.Logger;

import uk.ac.staffs.student.autopilot.packet.PacketBuilder;
import uk.ac.staffs.student.autopilot.views.APHciSwingPanel;

public class Autopilot_HCI_INIT implements ActionListener, WindowListener {

    private final APHciSwingPanel autopilot;
    private final SerialPortManager spm;
    private PacketBuilder pb;
    private final JFrame frame;
    public static Logger logger = Logger.getLogger(Autopilot_HCI_INIT.class);

    public Autopilot_HCI_INIT() {

        autopilot = new APHciSwingPanel();
        frame = new JFrame("Autopilot HCI");
        frame.setBounds(100, 100, 700, 555);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(autopilot);
        frame.setVisible(true);
        final Container con = frame.getContentPane();
        spm = new SerialPortManager(autopilot);

        // pb = new PacketBuilder();
        // pb.addObserver(autopilot);

    }

    public static void main(final String args[]) {

        final Autopilot_HCI_INIT me = new Autopilot_HCI_INIT();

        // me.testChange();

    }

    public void testChange() {
        // pb.changeSomething();

    }

    @Override
    public void actionPerformed(final ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * @return the spm
     */
    public SerialPortManager getSpm() {
        return spm;
    }

    @Override
    public void windowOpened(final WindowEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void windowClosing(final WindowEvent e) {
        spm.close();
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void windowClosed(final WindowEvent e) {

        spm.close();
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void windowIconified(final WindowEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void windowDeiconified(final WindowEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void windowActivated(final WindowEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void windowDeactivated(final WindowEvent e) {
        // throw new UnsupportedOperationException("Not supported yet.");
    }

}
